﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using System.Text;
using Global.Class.Library;

namespace DataTransferObject
{

    public class MarketingProgramMaster : NotifyPropertyChangeObject
    {

        private int marketingProgramID;

        private string reference;
        private string referenceCode;
        private string marketingProgramName;
        private string marketingProgramSubName;
        private int salesmenID;
        private int marketingProgramGroupID;
        private int marketingProgramTypeID;
        private int customerChannelID;
        private int timeBaseID;

        private DateTime beginingDate;
        private DateTime endingDate;

        private double salesTarget;
        private double marketingBudget;

        private string remarks;
        private bool inActive;



        public MarketingProgramMaster()
        {
            GlobalDefaultValue.Apply(this);

            this.BeginingDate = DateTime.Today;
            this.EndingDate = DateTime.Today.AddDays(365);
        }

        #region Properties


        [DefaultValue(-1)]
        public int MarketingProgramID 
        {
            get { return this.marketingProgramID; }
            set { ApplyPropertyChange<MarketingProgramMaster, int>(ref this.marketingProgramID, o => o.MarketingProgramID, value); }
        }


        [DefaultValue("")]
        public string Reference
        {
            get { return this.reference; }
            set { ApplyPropertyChange<MarketingProgramMaster, string>(ref this.reference, o => o.Reference, value); }
        }

        [DefaultValue("")]
        public string ReferenceCode
        {
            get { return this.referenceCode; }
            set { ApplyPropertyChange<MarketingProgramMaster, string>(ref this.referenceCode, o => o.ReferenceCode, value); }
        }

        [DefaultValue("")]
        public string MarketingProgramName
        {
            get { return this.marketingProgramName; }
            set { ApplyPropertyChange<MarketingProgramMaster, string>(ref this.marketingProgramName, o => o.MarketingProgramName, value); }
        }


        [DefaultValue("")]
        public string MarketingProgramSubName
        {
            get { return this.marketingProgramSubName; }
            set { ApplyPropertyChange<MarketingProgramMaster, string>(ref this.marketingProgramSubName, o => o.MarketingProgramSubName, value); }
        }


        [DefaultValue("")]
        public string Remarks
        {
            get { return this.remarks; }
            set { ApplyPropertyChange<MarketingProgramMaster, string>(ref this.remarks, o => o.Remarks, value); }
        }


        [DefaultValue(0)]
        public int SalesmenID
        {
            get { return this.salesmenID; }
            set { ApplyPropertyChange<MarketingProgramMaster, int>(ref this.salesmenID, o => o.SalesmenID, value); }
        }


        [DefaultValue(0)]
        public int MarketingProgramGroupID
        {
            get { return this.marketingProgramGroupID; }
            set { ApplyPropertyChange<MarketingProgramMaster, int>(ref this.marketingProgramGroupID, o => o.MarketingProgramGroupID, value); }
        }


        [DefaultValue(0)]
        public int MarketingProgramTypeID
        {
            get { return this.marketingProgramTypeID; }
            set { ApplyPropertyChange<MarketingProgramMaster, int>(ref this.marketingProgramTypeID, o => o.MarketingProgramTypeID, value); }
        }


        [DefaultValue(0)]
        public int CustomerChannelID
        {
            get { return this.customerChannelID; }
            set { ApplyPropertyChange<MarketingProgramMaster, int>(ref this.customerChannelID, o => o.CustomerChannelID, value); }
        }


        [DefaultValue(0)]
        public int TimeBaseID
        {
            get { return this.timeBaseID; }
            set { ApplyPropertyChange<MarketingProgramMaster, int>(ref this.timeBaseID, o => o.TimeBaseID, value); }
        }


        [DefaultValue(typeof(DateTime), "01/01/1900")]
        public DateTime BeginingDate
        {
            get { return this.beginingDate; }
            set { ApplyPropertyChange<MarketingProgramMaster, DateTime>(ref this.beginingDate, o => o.BeginingDate, value); }
        }

        [DefaultValue(typeof(DateTime), "01/01/1900")]
        public DateTime EndingDate
        {
            get { return this.endingDate; }
            set { ApplyPropertyChange<MarketingProgramMaster, DateTime>(ref this.endingDate, o => o.EndingDate, value); }
        }



        [DefaultValue(0)]
        public double SalesTarget
        {
            get { return this.salesTarget; }
            set { ApplyPropertyChange<MarketingProgramMaster, double>(ref this.salesTarget, o => o.SalesTarget, value); }
        }


        [DefaultValue(0)]
        public double MarketingBudget
        {
            get { return this.marketingBudget; }
            set { ApplyPropertyChange<MarketingProgramMaster, double>(ref this.marketingBudget, o => o.MarketingBudget, value); }
        }


        [DefaultValue(false)]
        public bool InActive
        {
            get { return this.inActive; }
            set { ApplyPropertyChange<MarketingProgramMaster, bool>(ref this.inActive, o => o.InActive, value); }
        }

        #endregion


        protected override System.Collections.Generic.List<ValidationRule> CreateRules()
        {
            List<ValidationRule> validationRules = base.CreateRules();
            validationRules.Add(new SimpleValidationRule("MarketingProgramGroupID", "Please select a program group.", delegate { return this.MarketingProgramGroupID > 0; }));
            validationRules.Add(new SimpleValidationRule("MarketingProgramTypeID", "Please select a program type.", delegate { return this.MarketingProgramTypeID > 0; }));
            validationRules.Add(new SimpleValidationRule("CustomerChannelID", "Please select a channel.", delegate { return this.CustomerChannelID > 0; }));
            validationRules.Add(new SimpleValidationRule("TimeBaseID", "Please select a time base.", delegate { return this.TimeBaseID > 0; }));
            validationRules.Add(new SimpleValidationRule("SalesmenID", "Person in charge cannot be empty.", delegate { return this.SalesmenID > 0; }));
            validationRules.Add(new SimpleValidationRule("Reference", "Reference cannot be blank.", delegate { return this.Reference.Length != 0; }));
            validationRules.Add(new SimpleValidationRule("ReferenceCode", "Reference code cannot be blank.", delegate { return this.ReferenceCode.Length != 0; }));

            return validationRules;
        }

    }
}
